@extends('system.frame_layout')
<?php $parent_menu = "财务中心"; $menu_selected = "注册新会员";?>

@section('content')
    <div id="content-panel">
        <div class="row">
            <div class="col-xs-12">
                <div class="portlet light bordered">
                    <div class="portlet-title">
                        <div class="caption">
                            <i class="icon-social-dribbble font-dark hide"></i>
                            <span class="caption-subject font-dark bold">注册会员 Register User</span>
                        </div>
                    </div>
                    <div class="portlet-body">
                        <div class="form-group">
                            <form id="reg_form" action="{{route('reg.act')}}" method="post">
                                {!! csrf_field() !!}
                                <div class="form-body">

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            登录用户名 - Login User Name
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input name="username" type="text" class="form-control"
                                                       placeholder="请输入会员登录账号">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            登录密码 - Login Pass
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input id="userpass" name="userpass" type="password"
                                                       class="form-control" placeholder="请输入登录密码">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            确认登录密码 - Confirm Login Pass
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input name="reuserpass" type="password" class="form-control"
                                                       placeholder="请输入登录密码">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            交易密码 - Safe Pass
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input id="safepass" name="safepass" type="password"
                                                       class="form-control"
                                                       placeholder="请设定交易密码">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            确认交易密码 - Confirm Safe Pass
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input name="resafepass" type="password" class="form-control"
                                                       placeholder="请设定交易密码">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            选择会员等级 - Select VIP
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <select name="vip" class="form-control">
                                                <option value="1">银卡会员（0.00）</option>
                                                <option value="2">金卡会员（0.00）</option>
                                            </select>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            推荐人账号 - Recommend User
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input name="pname" type="text" class="form-control"
                                                       placeholder="请输入推荐人用户名">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            节点人账号 - Node User
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input name="nuser" type="text" class="form-control"
                                                       placeholder="请输入节点人用户名" value="{{$nuser->username or ""}}">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            报单中心 - Activate User
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input name="bdzx" type="text" class="form-control"
                                                       placeholder="请输入报单中心用户名">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <div class="col-xs-12">
                                            <button type="submit" class="btn blue-madison">
                                                <i class="iconfont icon-duihao"></i>&nbsp;立即注册
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('footer')
    <script type="text/javascript">
        $("#reg_form").validate({
            rules: {
                username: {
                    required: true,
                    minlength: 3,
                    maxlength: 30
                },
                userpass: {
                    required: true,
                    minlength: 6,
                    maxlength: 30
                },
                reuserpass: {
                    required: true,
                    equalTo: "#userpass"
                },
                safepass: {
                    required: true,
                    minlength: 6,
                    maxlength: 30
                },
                resafepass: {
                    required: true,
                    equalTo: "#safepass"
                },
                vip: "required",
                puser: {
                    required: true,
                    minlength: 3,
                    maxlength: 30
                },
                nuser: {
                    required: true,
                    minlength: 3,
                    maxlength: 30
                },
                bdzx: {
                    required: true,
                    minlength: 3,
                    maxlength: 30
                }
            }, errorPlacement: function (error, element) {
                $(element).closest(".input-row").find(".label-intro").html(error);
            },
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    dataType: "json",
                    type: "post",
                    success: function (data) {
                        if (data.code == 0) {
                            toastr["success"](data.msg);
                            setInterval(function () {
                                window.location = "{{route('sys.users',['flag'=>1])}}";
                            }, 2000);
                        } else {
                            toastr["error"](data.msg);
                        }
                    }
                });
            }
        });
    </script>
@endsection